#include<algorithm>

class Solution {
public:

    int  hash[100010] = { 0 };
    int maxLength(vector<int>& arr)
    {
        int ret = 1;

        int left = 0, right = 0;

        while (right < arr.size())
        {
            hash[arr[right]]++;
            while (hash[arr[right]] > 1)
            {
                hash[arr[left]]--;
                left++;
            }
            ret = max(ret, right - left + 1);
            right++;
        }

        return ret;
    }
};